package com.shanling.shanlingcontroller.utils;

import android.content.Context;
import android.os.CountDownTimer;
import android.widget.TextView;

import com.shanling.shanlingcontroller.R;

/**
 * Created by ch1 on 2019/9/30.
 */


public class CountDownTimerUtils extends CountDownTimer {
    private TextView mTextView;
    private Context context;
    public CountDownTimerUtils(Context context,TextView textView, long millisInFuture, long countDownInterval) {
        super(millisInFuture, countDownInterval);
        this.mTextView = textView;
        this.context=context;
    }

    @Override
    public void onTick(long millisUntilFinished) {
        mTextView.setClickable(false); //设置不可点击
        mTextView.setText(millisUntilFinished / 1000 + "s");  //设置倒计时时间
        mTextView.setTextColor(0xffCAB487);
    }
    @Override
    public void onFinish() {
        mTextView.setText(context.getString(R.string.reacquire));
        mTextView.setClickable(true);//重新获得点击
        mTextView.setTextColor(0xffAAAAAA);
    }
}


